// key
// CH:简体中文  EN:英文  KR:韩语 JP:日语  RS:俄语
//  FC:法语   GM :德语  ES: 西班牙语 MA:Malasia马拉西亚 AB:árabe 阿拉伯语

var language_arr = [
    {
        "CH":"CH",
        "EN":"EN",
        "HY": "HY",
        "RY": "RY",
    },
    {
        "CH":"时间加载中...",
        "EN":"Time Is Loading...",
    },
    {
        "CH":"硬件总览",
        "EN":"Hardware Overview",
    },
    {
        "CH":"剩余",
        "EN":"Remaining",
    },
    {
        "CH":"总硬盘",
        "EN":"Total Hard Disk",
    },
    {
        "CH":"总内存",
        "EN":"Total Memory",
    },
    {
        "CH":"故障率",
        "EN":"Failure Rate",
    },
    {
        "CH":"收益总览",
        "EN":"Return Summary",
    },
    {
        "CH":"今日收益",
        "EN":"Today'S Earnings",
    },
    {
        "CH":"本周收益",
        "EN":"Earnings this week",
    },
    {
        "CH":"本月收益",
        "EN":"Month Earnings",
    },
    {
        "CH":"今日产值",
        "EN":"Today'S Production Value",
    },
    {
        "CH":"日均产出",
        "EN":"Average Daily Output",
    },
    {
        "CH":"全网概览",
        "EN":"Overview Of The Whole Network",
    },
    {
        "CH":"区块高度:",
        "EN":"Height:",
    },
    {
        "CH":"总流通量：",
        "EN":"Circulation",
    },
    {
        "CH":"活跃矿工数：",
        "EN":"Miner:",
    },
    {
        "CH":"24H产出：",
        "EN":"24H Output:",
    },
    {
        "CH":"总质押量：",
        "EN":"Total pledge:",
    },
    {
        "CH":"质押量:",
        "EN":"Pledge Amount:",
    },
    {
        "CH":"全网算力:",
        "EN":"Network computing power:",
    },
    {
        "CH":"总账户数:",
        "EN":"Total number of accounts:",
    },
    {
        "CH":"24H基础手续费率走势",
        "EN":"24H Basic Fee Rate Trend",
    },
    {
        "CH":"全网有效算力",
        "EN":"The Effective Computing Power Of The Entire Network",
    },
    {
        "CH":"全网算力",
        "EN":"Network computing power",
    },
    {
        "CH":"矿工",
        "EN":"Miner",
    },
    {
        "CH":"钱包",
        "EN":"Wallet",
    },
    {
        "CH":"区块高度",
        "EN":"Block Height",
    },
    {
        "CH":"挖矿排行榜",
        "EN":"Mining Ranking",
    },
    {
        "CH":"有效算力",
        "EN":"Effective Computing Power",
    },
    {
        "CH":"总奖励",
        "EN":"Total Reward",
    },
    {
        "CH":"",
        "EN":"",
    },
];

var $cl = {};
$cl.change_all_language_event = function(){
    if (!window.localStorage.getItem('langName')) {
        window.localStorage.setItem('language_type','{"old_language":"' + 'CH' + '","language":"EN"}');
        window.localStorage.setItem('langName', 'English');
        window.localStorage.setItem('langType', 'EN');
    }
    var language_type = window.localStorage.getItem('language_type');
    if(language_type){
        language_type = JSON.parse(language_type);
        var old_language_type = language_type.old_language;
        var current_language_type = language_type.language;
        $('.change_luange_in').each(function(index,ele){
            if($(ele).get(0).tagName == 'INPUT' || $(ele).get(0).tagName == 'TEXTAREA'){
                var current_language = $(ele).attr('placeholder');
                for (var i = 0; i < language_arr.length; i++) {
                    if(current_language == language_arr[i][old_language_type]){
                        $(ele).attr('placeholder',language_arr[i][current_language_type])
                        break;
                    }
                }
            }else{
                var current_language = $(ele).html();
                for (var i = 0; i < language_arr.length; i++) {
                    if(current_language == language_arr[i][old_language_type]){
                        $(ele).html(language_arr[i][current_language_type])
                        break;
                    }
                }
            }
        })
    }else{
        $('.change_luange_in').each(function(index,ele){
            if($(ele).get(0).tagName == 'INPUT' || $(ele).get(0).tagName == 'TEXTAREA'){
                var current_language = $(ele).attr('placeholder');
                for (var i = 0; i < language_arr.length; i++) {
                    if(current_language == language_arr[i]['CH']){
                        $(ele).attr('placeholder',language_arr[i]['CH'])
                    }
                }
            }else{
                var current_language = $(ele).html();
                for (var i = 0; i < language_arr.length; i++) {
                    if(current_language == language_arr[i]['CH']){
                        $(ele).html(language_arr[i]['CH'])
                    }
                }
            }
        })
        return;
    }
}

// 切换js中的语言
$cl.change_js_language_event = function(word){
    var current_language = word;
    // alert(word)
    // $api.rmStorage('language_type');
    var language_type = window.localStorage.getItem('language_type');
    if(language_type){
        language_type = JSON.parse(language_type)
        var old_language_type = language_type.old_language;
        var current_language_type = language_type.language;
        for (var i = 0; i < language_arr.length; i++) {
            if(current_language == language_arr[i][old_language_type]){
                return language_arr[i][current_language_type];
            }
        }
    }else{
        for (var i = 0; i < language_arr.length; i++) {
            if(current_language == language_arr[i]['CH']){
                // alert(language_arr[i][current_language_type])
                return language_arr[i]['CH'];
            }
        }
        // return word;
    }
}
